package com.llt.user.controller.user;


import com.llt.common.core.controller.BaseController;
import com.llt.common.core.domain.R;
import com.llt.common.core.domain.TableDataInfo;
import com.llt.user.aspect.CheckUserStatus;
import com.llt.user.domain.exam.ExamDTO;
import com.llt.user.domain.exam.dto.ExamQueryDTO;
import com.llt.user.service.user.IUserExamService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author llt
 * @since 2024-11-06
 */
@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {

    @Autowired
    private IUserExamService userExamService;

    /**
     * 报名参赛
     */
    @CheckUserStatus
    @PostMapping("/enter")
    public R<Void> enter(@RequestBody ExamDTO examDTO) {
        return toR(userExamService.enter(examDTO.getExamId()));
    }

    /**
     * 我的竞赛列表
     */
    @RequestMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
        return userExamService.list(examQueryDTO);
    }
}
